<template>
	<view v-if='screenWidth>480' class="flex-shrink">
		<view class="header_bg">
			<view class="__inner flex justify-between align-center py-2" style="height: 50%;">
				<view class="flex align-center">
					<image @click="handleIndex" style="width: 200rpx; height: 150rpx" src="@/static/icon/logo2.png"
						mode="aspectFit"></image>
					<image @click="handleIndex" style="width: 200rpx; height: 150rpx" src="@/static/icon/logo1.jpg"
						mode="aspectFit"></image>
					<text class="font-weight-bold mr-7"
						style="color: rgb(21,100,38);font-size: 80rpx;margin-left: 100rpx;">合美供销云平台<text
							style="font-size: 40rpx;" v-if="shopFlag">___商城</text></text>

				</view>
				<!-- 时间和定位 -->
				<view style="width: 20%;cursor: pointer;" class="flex flex-column justify-between font align-center">
					<text class="">{{ NowDate }}</text>
					<view class="flex justify-center align-center ">
						<uni-icons type="location-filled" size="20"></uni-icons>
						{{user_location}}
					</view>

				</view>
			</view>
		</view>

	</view>

</template>

<script>
	import times from "@/static/js/utils.js";
		import {getIPResolutionAction} from '@/static/js/GeneralUtil.js'
	import {
		getInquiryTourist
	} from "@/api/global.js"

	const app = getApp();
	export default {
		name: "yHeader",
		props: {
			current: {
				type: Number,
				default: 1
			},
			screenWidth: {
				type: Number,
				default: 1200
			},
			isTabs: {
				type: Boolean,
				default: true
			},
			shopFlag: {
				type: Boolean,
				default: false
			}
		},
		data() {
			return {
				search_good: '',
				userInfo: uni.getStorageSync('loginInfo').token,
				showRight: false,
				isShowNav: false,
				NowDate: "",
				Name: uni.getStorageSync('loginInfo').token ? uni.getStorageSync('loginInfo').username : '',
				Phone: uni.getStorageSync('loginInfo').token ? uni.getStorageSync('loginInfo').use.slice(7, 11) : '',
				user_location: '',
				isLogin: uni.getStorageSync('loginInfo').token ? true : false,
				value: 0,
				ThemeColors: app.globalData.ThemeColors,
				// #99
				tabs: [],
				clientIP: '',
			}
		},
		mounted() {
			this.NowDate = times.NowTime();
			if (uni.getStorageSync('loginInfo').token) { //本地存储地址
				this.isLogin = true
				this.Phone = uni.getStorageSync('loginInfo').use.slice(7, 11)
				this.Name = uni.getStorageSync('loginInfo').username
			} else {
				this.isLogin = false
			}
			this.getUserLoction();
			// this.getUnread();
			this.getData()
		},
		methods: {
			shopClick() {
				window.location.href = 'https://' + app.globalData.Domain_WZYM + '/dist/h5XKLJ/htmlpage/tabs.html'
			},
			// 商品搜索
			search_goodClick() {
				if (this.search_good) {
					uni.navigateTo({
						url: '/pages/search/search?gd_name=' + this.search_good
					})
				}
				this.search_good = ''
			},
			async getData() {
				const res = await getInquiryTourist({
					Data: 'group_tab',
					isNullEnterprise: true
				})
				console.log(res, 'daohnag');
				if (res) {
					this.tabs = res
				}
			},
			// 获取未读的数据
			// async getUnread() {
			// 	const res = await getUnreadMessage({
			// 		data: {}
			// 	});
			// 	this.value = res.total
			// },
			// 点击图标跳转未读的拒绝合同
			iconsEmail() {
				uni.navigateTo({
					url: '/pages/backend/view/messagelist?fromPage=myPreviousPage' // 替换为你实际的目标页面路径
				});
			},

			// 打开窗口
			showDrawer(e) {
				console.log(e);
				this.$refs[e].open()
			},
			// 关闭窗口
			closeDrawer(e) {
				this.$refs[e].close()
			},
			// 抽屉状态发生变化触发
			change(e, type) {
				console.log((type === 'showLeft' ? '左窗口' : '右窗口') + (e ? '打开' : '关闭'));
				this[type] = e
			},
			showNav() {
				this.isShowNav = !this.isShowNav;
			},
			getUserLoction() {
				getIPResolutionAction((data)=>{
					this.user_location = data.province + data.city + data.district;
				})
				// this.user_location = res.data.province + res.data.city + res.data.district;
				// console.log(this.user_location, '地址');
			},
			handleTabs(path) {
				console.log(path);
				if (path == '/pages/index/shop/shop' && this.screenWidth <= 480) {
					if (app.globalData.type != 'wechat') {
						window.location.href = 'https://' + app.globalData.Domain_WZYM + '/dist/h5XKLJShop/index.html'
					} else {
						window.location.href = 'https://' + app.globalData.Domain_WZYM + '/dist/h5XKLJ/htmlpage/tabs.html'
					}
				} else if (path == '/pages/index/shop/shop' && this.screenWidth >= 480) {
					window.location.href = 'https://' + app.globalData.Domain_WZYM + '/dist/h5XKLJShop/index.html'
				} else {
					uni.navigateTo({
						url: path,
					});
					// this.$emit('Tabs', path);
				}
			},
			handleIndex() {
				uni.navigateTo({
					url: '/pages/index/index'
				})
			},
			handleExit() {
				uni.removeStorageSync('loginInfo');
				this.isLogin = false
				this.$emit('EditLogin')
			},
			Login() {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			},
			Register() {
				uni.navigateTo({
					url: '/pages/login/register'
				})
			},
			handleBackend() {
				uni.navigateTo({
					url: '/pages/backend/index'
				})
			},
			handleExit() { //退出
				uni.removeStorageSync('loginInfo');
				this.isLogin = false
				if (window.location.hash != '#/pages/index/index') {
					uni.navigateTo({
						url: '/pages/index/index'
					})
				}
				window.history.go(0)
			},
		}
	}
</script>

<style lang="scss" scoped>
	.header_bg {
		background: linear-gradient(to bottom, #00990060, #00990050 50%, #00990060);
	}

	.icon-triangle-down {
		width: 0;
		height: 0;
		margin-left: 5px;
		border: 4px solid #535b62;
		border-right-color: transparent;
		border-left-color: transparent;
		border-bottom: none;
		/*兼容IE6及其以下*/
		_border-right-color: #fff;
		_border-right-color: #fff;
		position: absolute;
		top: 20px;
	}

	.drop-down:hover .icon-triangle-down {
		border-top: none;
		border-bottom-width: 4px;
		border-bottom-style: solid;
		// border-bottom-colors: var(--color);
	}

	.border-button {
		border-width: 5rpx;
		border-style: solid;
		box-sizing: border-box;
	}

	.hover:hover {
		text-decoration: underline;
		color: rgb(96, 127, 69);
	}

	.hovers:hover {
		text-decoration: underline;
		color: #dc3545;
	}

	.ydd {
		.ccyc::-webkit-scrollbar {
			display: none;
		}

		.nav-container {
			width: 100%;
			white-space: nowrap;

		}

		.nav {
			display: flex;
			white-space: nowrap;
		}

		.nav-item {
			display: inline-block;
			padding: 10px;
			margin: 0 10px;
			border: 1px solid #ccc;
			border-radius: 5px;
			cursor: pointer;
		}

		.nav-item:hover {
			background-color: #eee;
		}
	}

	.nav {
		height: 100%;
		// background-color: red;
		display: flex;
		justify-content: space-between;
		margin: 10rpx auto;
		padding: 10rpx;
	}

	.icon {
		margin: 0 10rpx;
		width: 60rpx;
		height: 60rpx;
		border: 1px solid aliceblue;
		border-radius: 10rpx;
		background-color: aliceblue;
		line-height: 60rpx;
		position: relative;
	}

	.navs-1 {
		width: 300rpx;
		height: 300rpx;
		background-color: #7bca89;
		display: flex;
		flex-direction: column;
		position: absolute;
		top: -50px;
		right: 400rpx;

		.item-list {
			height: 200rpx;
			width: 200rpx;
			background-color: #dc3545;
			z-index: 20000000000000000000;
		}
	}

	.example-body {
		padding: 10px;
	}

	.scroll-view {
		/* #ifndef APP-NVUE */
		width: 100%;
		height: 100%;
		/* #endif */
		flex: 1
	}

	// 处理抽屉内容滚动
	.scroll-view-box {
		flex: 1;
		position: absolute;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
	}

	.info {
		padding: 15px;
		color: #666;
	}

	.info-text {
		font-size: 14px;
		color: #666;
	}

	.info-content {
		padding: 5px 15px;
	}

	.close {
		padding: 10px;
	}

	.email-phone {
		top: 30rpx;
		right: 0;
		position: absolute;

		>.badge-phone {
			position: absolute;
		}
	}

	.close_button {
		uni-button {
			background-color: #28a745 !important;
		}
	}

	.uni-drawer__content {
		border-left: 1px solid #28a745;
	}
</style>